package com.xdf.service;

import com.xdf.mapper.TransferMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xudengfeng
 * @date 2020/12/3 21:12
 */
@Service
public class TransferServiceImpl implements TransferService {

    @Autowired
    TransferMapper transferMapper;

    @Transactional
    @Override
    public boolean updateMoneyByName(String fromName, String toName, Double money) {

        int i1 = 0;
        int i2 = 0;
        i1 = transferMapper.updateMoneyByName(fromName, -money);
//            int i = 1 / 0;
        i2 = transferMapper.updateMoneyByName(fromName, money);

        if (i1 == 1 && i1 == 1) {
            return true;
        }
        return false;
    }
}
